from django_filters import rest_framework as filters

from bookshop import models


# 定义通过书籍名查找书籍的过滤化器类
class BookFilter(filters.FilterSet):
    class Meta:
        model = models.Book  # 模型名
        fields = {
            "name": ['exact'],
            # 定义name进行查找
        }


class TypeFilter(filters.FilterSet):
    class Meta:
        model = models.Types  # 模型名
        fields = {
            "name": ['exact'],
        }